package com.oocl.sc.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DbUtil {

	private static final String driverClass = "oracle.jdbc.OracleDriver";
	private static final String url = "jdbc:oracle:thin:@ITA-031-W7:1521:xe";
	private static final String username = "DAIGA";
	private static final String password = "DAIGA";

	public static Connection getConnection() {
		Connection connection = null;

		try {
			Class.forName(driverClass);
			connection = DriverManager.getConnection(url, username, password);
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		return connection;
	}

	public static void free(Connection conn, PreparedStatement st, ResultSet rs) {

		try {
			if (rs != null) {
				rs.close();
			}

			if (st != null) {
				st.close();
			}

			if (conn != null) {
				conn.close();
			}

		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

}
